home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / By the Book / Learn C++ (CodeWarrior) / Chap 08.05 - strstream / strstream.cp < prev    next >
Text File  |  1995-10-21  |  511b  |  27 lines

  1. #include <iostream.h>
  2. #include <strstream.h>
  3. //    Changed the file name from <strstrea.h>
  4. //    to <strstream.h> -- Dave Mark, 10/20/95
  5.  
  6. const short kBufferSize = 10;
  7.  
  8. //---------------------------------------  main()
  9.  
  10. int    main()
  11. {
  12.     char        buffer[ kBufferSize ];
  13.     ostrstream    ostr( buffer, kBufferSize );
  14.     short        i = 0;
  15.     
  16.     while ( ostr << (char)('a' + i) )
  17.         i++;
  18.     
  19.     cout << "Number of characters written: "
  20.             << i << '\n';
  21.     
  22.     buffer[ kBufferSize - 1 ] = '\0';
  23.     
  24.     cout << "Buffer contents: " << buffer;
  25.     
  26.     return 0;
  27. }